let formNewsDate=(val)=>{
	if(!val){
		return;
	}else{
		return val.split(' ')[0];
	}	
}
let substring =(val,len)=>{
	if(!val){
		return;
	}else{
		if(val.length>len+3){
			return val.substring(0,len);
		}else{
			return val;
		}
	}	
}
let formDate = (val)=>{
		if(!val){
			return ;
		}
		let date = new Date(val)		
		let [Y,M,D,h,m,s] = [date.getFullYear(),date.getMonth()+1,date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds()]
		let str = `${Y}-${M>9? M : '0'+M}-${D>9?D:'0'+D}  ${h>9?h:'0'+h}:${m>9?m:'0'+m}:${s>9?s:'0'+s}`
		return (str);
	}
let formDateTime = (val)=>{	//小时分钟秒
		if(!val){
			return ;
		}
	
		let date = new Date(val)		
		let [h,m,s] = [date.getHours(),date.getMinutes(),date.getSeconds()]
		let str = `${h>9?h:'0'+h}:${m>9?m:'0'+m}:${s>9?s:'0'+s}`
		return (str);
	}
let formDateYear = (val)=>{	//年
		if(!val){
			return ;
		}
	
		let date = new Date(val)		
		let [Y,M,D] = [date.getFullYear(),date.getMonth()+1,date.getDate()]
		let str = `${Y}.${M>9? M : '0'+M}.${D>9?D:'0'+D}`
		return (str);
	}

export default {
	formDate,
	formDateTime,
	formDateYear,
	formNewsDate,
	substring
}



